require 'will_paginate'
class BasicareasController < ApplicationController
  
  
  # GET /basicareas
  # GET /basicareas.xml
  def index
    
    @nome = params[:nome]
    @basicareas =  Basicarea.search @nome, params[:page]

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @basicareas }
    end
  end

  # GET /basicareas/1
  # GET /basicareas/1.xml
  def show
    @basicarea = Basicarea.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @basicarea }
    end
  end

  # GET /basicareas/new
  # GET /basicareas/new.xml
  def new
    @basicarea = Basicarea.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @basicarea }
    end
  end

  # GET /basicareas/1/edit
  def edit
    @basicarea = Basicarea.find(params[:id])
  end

  # POST /basicareas
  # POST /basicareas.xml
  def create
    @basicarea = Basicarea.new(params[:basicarea])

    @basicarea = modifica @basicarea,params[:basicarea]

    respond_to do |format|
      if @basicarea.save
        flash[:notice] = 'Basicarea was successfully created.'
        format.html { redirect_to(basicareas_url) }
        format.xml  { render :xml => @basicarea, :status => :created, :location => @basicarea }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @basicarea.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /basicareas/1
  # PUT /basicareas/1.xml
  def update
    @basicarea = Basicarea.find(params[:id])

    respond_to do |format|
      if @basicarea.update_attributes(params[:basicarea])
        flash[:notice] = 'Basicarea was successfully updated.'
        format.html { redirect_to(basicareas_url) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @basicarea.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /basicareas/1
  # DELETE /basicareas/1.xml
  def destroy
    @basicarea = Basicarea.find(params[:id])
    @basicarea.destroy

    respond_to do |format|
      format.html { redirect_to(basicareas_url) }
      format.xml  { head :ok }
    end
  end
end
